<?php

namespace AuthDoctrine;

return array(
//	'static_salt' => 'aFGQ475SDsdfsaf2342', // I am going to move it to global.php. It should be accessable everywhere
	'controllers' => array(
        'invokables' => array(
            'AuthDoctrine\Controller\Index' => 'AuthDoctrine\Controller\IndexController',	
            'AuthDoctrine\Controller\Registration' => 'AuthDoctrine\Controller\RegistrationController',	
            //'AuthDoctrine\Controller\Admin' => 'AuthDoctrine\Controller\AdminController',	
        ),
	),
    'router' => array(
        'routes' => array(
			'authdoctrine' => array(
				'type'    => 'Literal',
				'options' => array(
					'route'    => '/authdoctrine',
					'defaults' => array(
						'__NAMESPACE__' => 'AuthDoctrine\Controller',
						'controller'    => 'Index',
						'action'        => 'index',
					),
				),
				'may_terminate' => true,
				'child_routes' => array(
					'default' => array(
						'type'    => 'Segment',
						'options' => array(
							'route'    => '/[:controller[/:action[/:id]]]',
							'constraints' => array(
								'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
								'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
								'id'     	 => '[a-zA-Z0-9_-]*',
							),
							'defaults' => array(
							),
						),
					),
				),
			),			
		),
	),
    'view_manager' => array(
        'template_path_stack' => array(
            'authentity' => __DIR__ . '/../view'
        ),
		
		'display_exceptions' => true,
    ),
    
     // Doctrine config
    'doctrine' => array(
        'authentication' => array( // this part is for the Auth adapter from DoctrineModule/Authentication
            'orm_default' => array(
                'object_manager' => 'Doctrine\ORM\EntityManager',
				// object_repository can be used instead of the object_manager key
                'identity_class' => 'AuthDoctrine\Entity\Users', //'Application\Entity\User',
                'identity_property' => 'usrName', // 'username', // 'email',
                'credential_property' => 'usrPassword', // 'password',
                'credential_callable' => function(Entity\Users $user, $passwordGiven) { 
					if ($user->getUsrPassword() == md5('aFGQ475SDsdfsaf2342' . $passwordGiven . $user->getUsrPasswordSalt()) && $user->getUsrActive() == 1) {
						return true;
					}
					else {
						return false;
					}
                },
            ),
        ),
        'driver' => array(
            __NAMESPACE__ . '_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
                )
            )
        )
    )
	/*'service_manager' => array(
		// added for AuthDoctrineentication and AuthDoctrineorization. Without this each time we have to create a new instance.
		// This code should be moved to a module to allow Doctrine to overwrite it
		'aliases' => array( // !!! aliases not alias
			'Zend\AuthDoctrineentication\AuthDoctrineenticationService' => 'my_auth_service',
		),
		'invokables' => array(
			'my_auth_service' => 'Zend\AuthDoctrineentication\AuthDoctrineenticationService',
		),
	),*/
);